export class Message {

  private static msgs: any;

  static getMsg(id: string, ...args) {
    if (!this.msgs) {
      this.msgs = window.messages;
    }

    let msg = this.msgs[id];

    for (let i = 0; i < args.length; i++) {
      let re = new RegExp('\\{' + (i + 1) + '\\}', 'gm');
      msg = msg.replace(re, args[i]);
    }

    return msg;
  }

}
